<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2025/5/26
  Time: 21:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>用户管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link type="text/css" rel="stylesheet" href="css/index.css">
    <link type="text/css" rel="stylesheet" href="css/base.css">
</head>
<body>

<div class="container">
    <jsp:include page="header.jsp"></jsp:include>
    <div class="main user-list">
        <button onclick="location.href='/admin/user_add.jsp'">+添加新用户</button><br><br>

        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>头像</th>
                    <th>昵称</th>
                    <th>用户名</th>
                    <th>邮箱</th>
                    <th>密码</th>
                    <th>创建时间</th>
                    <th>身份</th>
                    <th>操作</th>
                </tr>

            </thead>
            <tbody>
                <c:forEach items="${userList}" var="u">
                    <tr>
                        <td>${u.id}</td>
                        <td><img src="${pageContext.request.contextPath}${u.avatar}" width="100px" height="100px"></td>
                        <td>${u.nickname}</td>
                        <td>${u.username}</td>
                        <td>${u.email}</td>
                        <td>${u.password}</td>
                        <td>${u.create_time}</td>
                            <%--                    model中添加is_admin--%>
                        <td>
                            <c:choose>
                                <c:when test="${u.admin=='true'}">管理员</c:when>
                                <c:otherwise>普通用户</c:otherwise>
                            </c:choose>
                        </td>
                        <td class="table-actions">
                            <button class="delete-btn" onclick="location.href='/admin/user_delete?id=${u.id}'">删除</button>
                        </td>
                    </tr>
                </c:forEach>
            </tbody>
        </table>
    </div>
</div>

</body>
</html>
